package com.api.shopapi.service.impl;

import com.api.shopapi.entity.CheckinSetmeal;
import com.api.shopapi.mapper.CheckinSetmealMapper;
import com.api.shopapi.service.CheckinSetmealService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author maochuan
 */
@Service("CheckinSetmealServiceImplOne")
public class CheckinSetmealServiceImpl implements CheckinSetmealService {
    @Autowired
    private CheckinSetmealMapper checkinSetmealMapper;

    @Override
    public int insert(CheckinSetmeal checkinSetmeal) {
        return checkinSetmealMapper.insert(checkinSetmeal);
    }

    @Override
    public int updateByCheckinSetmealCode(CheckinSetmeal checkinSetmeal) {
        return checkinSetmealMapper.updateByCheckinSetmealCode(checkinSetmeal);
    }

    @Override
    public List<CheckinSetmeal> getListAll(String institutionCode) {
        return checkinSetmealMapper.getListAll(institutionCode);
    }

    @Override
    public CheckinSetmeal getByCheckinSetmealCode(String checkinSetmealCode) {
        return checkinSetmealMapper.getByCheckinSetmealCode(checkinSetmealCode);
    }

    @Override
    public CheckinSetmeal getByInstitutionCodeAndName(String institutionCode, String name) {
        return checkinSetmealMapper.getByInstitutionCodeAndName(institutionCode,name);
    }

    @Override
    public PageInfo<CheckinSetmeal> getPageList(int pageIndex, int pageSize, String institutionCode) {
        PageHelper.startPage(pageIndex, pageSize);
        List<CheckinSetmeal> checkinSetmeals = checkinSetmealMapper.getListByInstitutionCode(institutionCode);
        PageInfo<CheckinSetmeal> pageInfo = new PageInfo<>(checkinSetmeals);
        return pageInfo;
    }

    @Override
    public
    PageInfo<CheckinSetmeal> pageByGovCode(int pageIndex, int pageSize, String governmentCode){
        PageHelper.startPage(pageIndex, pageSize);
        List<CheckinSetmeal> checkinSetmeals = checkinSetmealMapper.listByGovCode(governmentCode);
        PageInfo<CheckinSetmeal> pageInfo = new PageInfo<>(checkinSetmeals);
        return pageInfo;
    }

}
